package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.ActivitycodebatchContinuation;
import com.ktgj.service.service.IActivitycodebatchContinuationService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 活动码续码记录Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/continuation")
public class ActivitycodebatchContinuationController extends BaseController
{
    @Autowired
    private IActivitycodebatchContinuationService activitycodebatchContinuationService;

    /**
     * 查询活动码续码记录列表
     */
    @PreAuthorize(hasPermi = "service:continuation:list")
    @GetMapping("/list")
    public TableDataInfo list(ActivitycodebatchContinuation activitycodebatchContinuation)
    {
        startPage();
        List<ActivitycodebatchContinuation> list = activitycodebatchContinuationService.selectActivitycodebatchContinuationList(activitycodebatchContinuation);
        return getDataTable(list);
    }

    /**
     * 导出活动码续码记录列表
     */
    @PreAuthorize(hasPermi = "service:continuation:export")
    @Log(title = "活动码续码记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivitycodebatchContinuation activitycodebatchContinuation) throws IOException
    {
        List<ActivitycodebatchContinuation> list = activitycodebatchContinuationService.selectActivitycodebatchContinuationList(activitycodebatchContinuation);
        ExcelUtil<ActivitycodebatchContinuation> util = new ExcelUtil<ActivitycodebatchContinuation>(ActivitycodebatchContinuation.class);
        util.exportExcel(response, list, "活动码续码记录数据");
    }

    /**
     * 获取活动码续码记录详细信息
     */
    @PreAuthorize(hasPermi = "service:continuation:query")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(activitycodebatchContinuationService.selectActivitycodebatchContinuationById(recordId));
    }

    /**
     * 新增活动码续码记录*/
    @PreAuthorize(hasPermi = "service:continuation:add")
    @Log(title = "活动码续码记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitycodebatchContinuation activitycodebatchContinuation)
    {
        return toAjax(activitycodebatchContinuationService.insertActivitycodebatchContinuation(activitycodebatchContinuation));
    }

    /**
     * 修改活动码续码记录*/
    @PreAuthorize(hasPermi = "service:continuation:edit")
    @Log(title = "活动码续码记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivitycodebatchContinuation activitycodebatchContinuation)
    {
        return toAjax(activitycodebatchContinuationService.updateActivitycodebatchContinuation(activitycodebatchContinuation));
    }

    /**
     * 删除活动码续码记录*/
    @PreAuthorize(hasPermi = "service:continuation:remove")
    @Log(title = "活动码续码记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(activitycodebatchContinuationService.deleteActivitycodebatchContinuationByIds(recordIds));
    }
}
